<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="common/include :: header('修改流程定义')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-bpmnInfo-edit" >
<!--        <input type="hidden" name="id" id="bpmnInfoId">-->
        <input type="hidden" name="filePath" id="filePath"/>
        <div class="form-group">
            <label class="col-sm-3 control-label"></label><!--文件上传组件-->
            <div id="uploadBtn" class="col-sm-8 fileinput fileinput-new" data-provides="fileinput">
              <span class="btn btn-outline-secondary btn-file">
                <span class="fileinput-new">
                    <a class="btn btn-warning btn-sm" ><i class="fa fa-upload"></i>&nbsp;流程文件部署</a>
                </span>
               <input type="file" name="file"  id="bpmnInfoinition" multiple>
              </span>
                <span class="fileinput-filename"></span>
                <a href="#" class="close fileinput-exists" data-dismiss="fileinput" style="float: none">&times;</a>
            </div>
        </div>

        <div class="form-group">

            <label class="col-sm-3 control-label">流程类型：</label>
            <div class="col-sm-8">
                <select name="bpmnType" class="form-control m-b" th:with="type=${@dict.getType('bus_audit_type')}">
                    <option th:each="dict : ${type}" th:text="${dict.label}" th:value="${dict.value}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">部署流程的名字：</label>
            <div class="col-sm-8">
                <input type="text" name="deploymentName" class="form-control"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注信息：</label>
            <div class="col-sm-8">
                <textarea name="info" class="form-control"></textarea>
            </div>
        </div>
    </form>
</div>
    <th:block th:include="common/include :: footer" />
    <th:block th:include="common/include :: jasny-bootstrap" />
    <script th:inline="javascript">
        var prefix = ctx + "/business/bpmnInfo";
        $("#form-bpmnInfo-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {//提交表单
            if ($.validate.form()) {
                $.operate.save(prefix + "/deploy", $('#form-bpmnInfo-edit').serialize());
            }
        }

        //处理流程部署文件上传
        $("#uploadBtn").on("change.bs.fileinput", function (e) {
            var formdata = new FormData();
            formdata.append("file", $('#bpmnInfoinition')[0].files[0]);//获取上传的第一个文件
            $.ajax({
                url: prefix + '/upload',
                type:"POST",
                data:formdata,
                processData: false,
                contentType: false,
                success: function(result) {
                    //接受返回的参数数据date中的filePath内容,放入隐藏域将其用于下一步部署时的参数
                    $('#filePath').val(result.data)
                    $.operate.ajaxSuccess(result);//处理返回的数据的msg
                }
            })
        })

    </script>
</body>
</html>